//底部选项卡点击事件
tabclick();

var banl_kind = document.getElementById('banl_kind');
//	刷新按钮变色效果
refresh.addEventListener('touchstart', function() {
	refresh.style.background = '#D8D8D8'
});
refresh.addEventListener('touchend', function() {
	refresh.style.background = 'white';
	setTimeout(function() {
		refresh.style.display = 'none';
		get();
	}, 500)
});
function xf(i,b,data){
						document.getElementsByClassName(b)[i].addEventListener('tap',function () {
						console.log(i)
						if(localStorage.getItem("userid")) {
							window.location.href = data.data[i].murl;
						} else {
							var aa=data.data[i].murl;
							console.log(aa)
							localStorage.setItem("xfhref",aa);
							window.location.href = '../../HTML/login/login.html?islogin=2';
						}
				}) 
					}
function get() {
	//		银行列表
	$.ajax({
		type: 'get',
		url: httpAdress + '/api/card/bank/getallbank',
		contentType: "application/json; charset=utf-8",
		dataType: 'jsonp',
		jsonp: "callback",
		jsonpCallback: "successCallback",
		success: function(data) {
			var mydata = data.data;
			//          alert(JSON.stringify(data));
			//          alert(mydata[0].murl);
			var str = '';
			for(var i = 0; i < mydata.length; i++) {
				str +=
					$('<li class="mui-table-view-cell bankhref">' +
					'<a>' +
					'<img src="' + httpAdress + mydata[i].logo + '"/>' +
					'<span>' + mydata[i].name + '</span>' +
					'<p>' + mydata[i].info + '</p>' +
					'</a></li>').appendTo("#banl_kind");
					
					xf(i,"bankhref",data);
			}
			//			动态加载的银行列表
//			banl_kind.innerHTML = str;

			//信用卡推荐
			var bank_post = document.getElementById('bank_post');
			$.ajax({
				type: 'get',
				url: httpAdress + '/api/card/product/getindexproduct',
				contentType: "application/json; charset=utf-8",
				dataType: 'jsonp',
				jsonp: "callback",
				jsonpCallback: "successCallback",
				success: function(data) {
					var mydata = data.data;
					for(var i = 0; i < mydata.length; i++) {
						$(
							' <li  class="mui-table-view-cell mui-media listc">' +
							'<a>' +
							'<img class="mui-media-object mui-pull-left bank" src="' + httpAdress + mydata[i].logo + '">' +
							'<div class="mui-media-body">' +
							'<span class="mui-media-body-head">' + mydata[i].name + '</span></br>' +
							'<span class="btn">' + mydata[i].reason[0] + '</span>' +
							'<span class="btn">' + mydata[i].reason[1] + '</span></br>' +
							'<span class="num detail">' + mydata[i].count + '</span>' +
							'<span class="num detail">人</span><span class="num front">成功放款</span>' +
							'</div></a></li>').appendTo("#bank_post");
							xf(i,"listc",data);
					}
				},
				error: function() {
					mui.toast('加载失败，刷新一下');
					refresh.style.display = 'block';
				}
			});
		},
		error: function() {
			mui.toast('加载失败，刷新一下');
		}
	});
}
get();